package cn.buk.tms.entity.order.flight;

import cn.buk.tms.entity.order.OrderApprovalInfo;
import cn.buk.tms.entity.base.BaseOrderInfo;
import com.fasterxml.jackson.annotation.JsonFormat;

import jakarta.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static cn.buk.common.Constant.PSG_TYPE_ADU;
import static cn.buk.common.Constant.PSG_TYPE_CHD;
import static cn.buk.tms.common.constant.TmsOrderConstant.ORDER_PRICE_VERIFY_STATE_NONE;

/**
 * 机票订单
 *
 * @author yfdai
 */
@Entity
@Table(name = "t250",
        uniqueConstraints = @UniqueConstraint(
                name = "uk_t250",
                columnNames = {"enterprise_id", "order_no"}))
@AssociationOverride(name = "customer",
        joinColumns = @JoinColumn(name = "customer_id"),
        foreignKey = @ForeignKey(name = "fk_t250_customer")
)
@AssociationOverride(name = "supplier",
        joinColumns = @JoinColumn(name = "supplier_id"),
        foreignKey = @ForeignKey(name = "fk_t250_supplier")
)
@AssociationOverride(name = "paymentMethod",
        joinColumns = @JoinColumn(name = "payment_method_id"),
        foreignKey = @ForeignKey(name = "fk_t250_payment_method")
)
public class FlightOrder extends BaseOrderInfo {

  /**
   * 订单号
   */
  @Column(name = "order_no", length = 10, nullable = false)
  private String orderNo;

  /**
   * cz ndc 外部订单号
   */
  @Column(name = "external_order_no", length = 20)
  private String externalOrderNo;

  /**
   * 订单创建日期，搜索时会使用
   */
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  @Temporal(TemporalType.DATE)
  @Column(name = "create_date", nullable = false)
  private Date createDate;

  /**
   * 订单提交时间
   */
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "submit_time", insertable = false)
  private Date submitTime;

  /**
   * 小编码，代理人系统看到的
   */
  @Column(name = "pnr_no", length = 10)
  private String pnrNo;

  /**
   * 大编码，用于航司的B2B
   */
  @Column(name = "big_pnr_no", length = 10)
  private String bigPnrNo;


  @Column(name = "pnr_detail", length = 4000)
  private String pnrDetail;

  /**
   * 订单人数(passenger count)
   */
  @Column(name = "psg_count")
  private int psgCount;

  /**
   * 航段数
   */
  @Column(name = "seg_count")
  private int segCount;

  /**
   * 订单状态
   */
  private int status;

  /**
   * 显示状态：综合退票、改签、DETR信息显示给客户的状态
   * 1-部分使用
   * 2-全部使用
   * 4-部分改签
   * 8-全部改签
   * 16-部分退票
   * 32-全部退票
   */
  @Column(name = "show_status")
  private Integer showStatus;


  /**
   * 客人付款状态(只有付款类型非记账方式时才有用，指的是客人付给我们的情况）
   * 0 or null 未支付
   * 1 已收款 已支付(通过账单设置的已支付，客服操作）
   * 2 已销账 已支付（已销账，同步财务账单的状态）
   */
  @Column(name = "pay_status")
  private Integer payStatus;


  /**
   * 行程类型
   * 1-单程
   * 2－来回
   * 3－多程
   */
  @Column(name = "route_type")
  private int routeType;

  /**
   * 订单描述
   */
  @Column(name = "order_desc", length = 50)
  private String orderDesc;

  /**
   * 需要在此时间之前出票
   * ticketing time limit
   */
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
  @Temporal(TemporalType.TIMESTAMP)
  private Date tktl;

  // 成人部分的价格
  /**
   * 公布运价，也可以称之为航司指导价，票面价(不用于计算）,但在自动开票时用于对比价格
   */
  private double price;

  /**
   * 销售价（国内航班一般等同于price, 但机票代理可能会加价销售，也就是在航司的实际销售价格基础上加价）
   */
  private double parvalue;

  /**
   * 税（总税额）
   */
  private double tax;

  /**
   * 保险（0利润）
   */
  private double insurance;

  @Column(name = "service_charge")
  private double serviceCharge;

  /**
   * @deprecated 机票现在没有代理费率了，只有固定金额的代理费
   */
  @Deprecated
  @Column(name = "comm_rate")
  private Double commRate;

  /**
   * 代理费（航司给的）
   */
  private Double commission;

  /**
   * 代理费（机票代理自己额外定的）
   */
  private Double commission2;

  /**
   * @deprecated 机票没有代理费率了，所以此处的给客户的让扣扣率基本也没用了
   */
  @Deprecated
  @Column(name = "discount_rate")
  private double discountRate;

  private double discount;

  /**
   * 每个人实收的机票款
   */
  private double amount;

  /**
   * 成本（单张）
   */
  private Double cost;

  /**
   * 成人人数
   */
  @Column(name = "adult_count")
  private Integer adultCount;


  // 儿童部分的价格

  @Column(name = "price_chd")
  private Double chdPrice;

  @Column(name = "parvalue_chd")
  private Double chdParvalue;

  @Column(name = "tax_chd")
  private Double chdTax;

  @Column(name = "insurance_chd")
  private Double chdInsurance;

  @Column(name = "commission_chd")
  private Double chdCommission;

  @Column(name = "commission2_chd")
  private Double chdCommission2;

  @Column(name = "serviceCharge_chd")
  private Double chdServiceCharge;

  @Column(name = "discount_chd")
  private Double chdDiscount;

  @Column(name = "cost_chd")
  private Double chdCost;

  @Column(name = "amount_chd")
  private Double chdAmount;

  /**
   * 儿童人数
   */
  @Column(name = "child_count")
  private Integer childCount;

  // 婴儿部分的价格

  @Column(name = "price_inf")
  private Double infPrice;

  @Column(name = "parvalue_inf")
  private Double infParvalue;

  @Column(name = "tax_inf")
  private Double infTax;

  @Column(name = "insurance_inf")
  private Double infInsurance;

  @Column(name = "commission_inf")
  private Double infCommission;

  @Column(name = "commission2_inf")
  private Double infCommission2;

  @Column(name = "serviceCharge_inf")
  private Double infServiceCharge;

  @Column(name = "discount_inf")
  private Double infDiscount;

  @Column(name = "cost_inf")
  private Double infCost;

  @Column(name = "amount_inf")
  private Double infAmount;

  /**
   * 婴儿人数
   */
  @Column(name = "infant_count")
  private Integer infantCount;

  // 以下为成人 + 儿童 的总数
  /**
   * 订单的机票款总额
   */
  @Column(name = "total_amount")
  private double totalAmount;

  /**
   * 总成本
   */
  @Column(name = "total_cost")
  private Double totalCost;

  /**
   * 此订单的总利润
   */
  private Double profit;

  /**
   * 联系人（代订人）
   */
  @Column(length = 20)
  private String linkman;

  /**
   * 联系人手机
   */
  @Column(name = "link_mobile")
  private String linkMobile;

  /**
   * 联系人固话
   */
  @Column(length = 20, name = "link_phone")
  private String linkPhone;

  /**
   * 联系人邮箱
   */
  @Column(name = "link_email", length = 50)
  private String linkEmail;

  /**
   * 备注
   */
  @Column(length = 200)
  private String remark;

  /**
   * 是否需要发票或行程单
   * 0-不需要
   * 1-行程单
   * 2-发票
   * 3-信息单
   * 4-行程单 + 捆绑产品（比如30元航意险/人/航段）（用于前台系统）
   */
  @Column(name = "itinerary_type")
  private Integer itineraryType;

  /**
   * 配送单号, 以后配送的相关信息都保存到配送单DeliveryNote中
   */
  @Column(name = "delivery_note_no", length = 12)
  private String deliveryNoteNo;

  /**
   * 收件人
   * 以后移到配送单中
   */
  @Column(name = "itinerary_recipient")
  private String itineraryRecipient;

  /**
   * 收件人联系电话
   * 以后移到配送单DeliveryNote中
   */
  @Column(name = "itinerary_recipient_mobile")
  private String itineraryRecipientMobile;

  /**
   * 当itineraryType不为0时，此表示邮寄地址
   * 以后移到配送单DeliveryNote中
   */
  @Column(name = "itinerary_mailing_addr")
  private String itineraryMailingAddress;

  /**
   * 当itineraryType不为0时，邮寄状态
   * 0 - 未邮寄
   * 1 - 已邮寄
   * 以后移到配送单DeliveryNote中
   */
  @Column(name = "itinerary_mailing_status")
  private Integer itineraryMailingStatus;

  /**
   * 当itineraryType不为0时，此表示备注
   * 以后移到配送单中
   */
  @Column(name = "itinerary_mailing_memo")
  private String itineraryMailingMemo;

  /**
   * 打印次数
   */
  @Column(name = "itinerary_print_count")
  private Integer itineraryPrintCount;

  /**
   * 配送日期，移到DeliveryNote
   */
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  @Temporal(TemporalType.DATE)
  @Column(name = "delivery_date")
  private Date deliveryDate;

  /**
   * 出票日期
   */
  @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
  @Temporal(TemporalType.DATE)
  @Column(name = "etdz_date")
  private Date etdzDate;

  /**
   * 保存航班信息
   */
  @OneToMany(mappedBy = "order", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
  private List<FlightOrderFlight> flights;

  /**
   * 保存乘机人信息和票号
   */
  @OneToMany(mappedBy = "order", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
  private List<FlightOrderPassenger> passengers;


  @OneToMany(mappedBy = "order", cascade = {CascadeType.ALL}, fetch = FetchType.LAZY)
  private List<FlightOrderExtra> extras;

  /**
   * 是否国际票
   * 1 - 是
   */
  @Column(name = "intl_ticket")
  private Integer intlTicket;

  /**
   * 订单中的编码使用到的大客户号, 也就是policyCode对饮的keyCustomerNo
   * policyCode是本地定义的，keyCustomerNo是航司给的
   */
  @Column(name = "key_customer_no", length = 50)
  private String keyCustomerNo;

  /**
   * 预订渠道
   * null/-1: 前台生成的订单
   * 0: pnr导入或手工录入
   * 1：后台通过页面航班查找生成订单
   */
  @Column(name = "channel")
  private Integer bookingChannel;

  //自动出票相关的状态

  /**
   * 自动出票的状态
   * -1 / null: 未知
   * 0: 不自动出票
   * 1: 等待自动出票
   * 2: 自动出票中，等待用户确认出票金额（PAT:A出现多个价格的情况下）
   * 8: 自动出票完成
   */
  @Column(name = "auto_ticketing")
  private Integer autoTicketing;

  /**
   * 自动出票时需要选择的金额，为空或大于0的
   */
  @Column(name = "auto_ticketing_price")
  private Integer autoTicketingPrice;

  /**
   * 账单导入是否成功
   * null / 0 - 默认状态, 未导入
   * 1 - 导入成功
   */
  @Column(name = "bill_imported")
  private Integer billImported;

  /**
   * 机票私有政策代码
   */
  @Column(name = "policy_code", length = 50)
  private String policyCode;

  /**
   * 0 - 否，不是开GP机票
   * 1 - 是，该订单开GP机票
   */
  @Column(name = "gp_ticket")
  private Integer gpTicket;

  /**
   * 对应的总订单id
   */
  @Column(name = "blanket_order_id")
  private Integer blanketOrderId;

  /**
   * 订单金额是否已校验
   * null/0 - 未校验
   * 1 - 校验通过
   * 4 - 校验失败, 需要人工干预
   */
  @Column(name = "price_checked")
  private Integer priceChecked;

  /**
   * 验价完成时间
   */
  @Column(name = "price_check_time")
  @Temporal(TemporalType.TIMESTAMP)
  private Date priceCheckedTime;

  /**
   * 审批信息
   */
  @Embedded
  private OrderApprovalInfo approvalInfo;

  /**
   * 通知状态: 是否发送消息提醒给客服部门
   */
  @Column(name = "notify_status")
  private Integer notifyStatus;


  /**
   * PNR详情刷新状态
   * 1: 出票完成后已重新获取了pnr详情
   * 4: 获取失败
   */
  @Column(name = "pnr_refresh_status")
  private Integer pnrRefreshStatus;

  /**
   * DETR刷新状态
   * 0/null - 待更新
   * 1 - 已刷新
   * 2 - 已更新到FlightOrderTicket中
   * 4 - 找不到，应该是获取不到DETR信息，非授权OFFICE开票
   * 8 - 票号状态已到终态，无需再检查
   */
  @Column(name = "detr_refresh_status")
  private Integer detrRefreshStatus;

  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "detr_refresh_time")
  private Date detrRefreshTime;

  /**
   * 通知信息类型
   * 0/null - 无
   * 1 - 航班变更通知
   */
  @Column(name = "notice_type")
  private Integer noticeType;

  /**
   * 通知信息内容
   */
  @Column(name = "notice_content", length = 100)
  private String noticeContent;

  /**
   * 通知信息是否确认阅读了
   * 0/null - 未读
   * 1 - 已读
   */
  @Column(name = "notice_confirmed")
  private Integer noticeConfirmed;

  /**
   * 通知发送的时间
   */
  @Temporal(TemporalType.TIMESTAMP)
  @Column(name = "notice_time")
  private Date noticeTime;


  @Transient
  private FlightOrderCancelRequest cancelRequest;

  @Transient
  private List<FlightOrderTicket> tickets;

  public String getRouteDetail() {
    StringBuilder sb = new StringBuilder();
    for (FlightOrderFlight flight : flights) {
      if (sb.length() > 0) {
        sb.append("//");
      }
      sb.append(flight.getFlight().getRouteDetail());
    }

    return sb.toString();
  }


  public List<FlightOrderFlight> getFlights() {
    if (flights == null) {
      flights = new ArrayList<>();
    }
    return flights;
  }

  public void setFlights(List<FlightOrderFlight> flights) {
    this.flights = flights;
  }

  public List<FlightOrderPassenger> getPassengers() {
    if (passengers == null) {
      passengers = new ArrayList<>();
    }
    return passengers;
  }

  public void setPassengers(List<FlightOrderPassenger> passengers) {
    this.passengers = passengers;
  }

  public int getStatus() {
    return status;
  }

  public void setStatus(int status) {
    this.status = status;
  }


  public String getPnrNo() {
    return pnrNo;
  }

  public void setPnrNo(String pnrNo) {
    this.pnrNo = pnrNo;
  }

  public Date getCreateDate() {
    return createDate;
  }

  public void setCreateDate(Date createDate) {
    this.createDate = createDate;
  }


  public String getPnrDetail() {
    return pnrDetail;
  }

  public void setPnrDetail(String pnrDetail) {
    if (pnrDetail != null && pnrDetail.length() > 4000) {
      pnrDetail = pnrDetail.substring(0, 3500);
    }
    this.pnrDetail = pnrDetail;
  }

  public int getPsgCount() {
    return psgCount;
  }

  public void setPsgCount(int psgCount) {
    this.psgCount = psgCount;
  }

  public int getSegCount() {
    return segCount;
  }

  public void setSegCount(int segCount) {
    this.segCount = segCount;
  }


  public int getRouteType() {
    return routeType;
  }

  public void setRouteType(int routeType) {
    this.routeType = routeType;
  }

  public String getOrderDesc() {
    return orderDesc;
  }

  public void setOrderDesc(String orderDesc) {
    this.orderDesc = orderDesc;
  }

  public String getRemark() {
    return remark == null ? "" : remark.trim();
  }

  public void setRemark(String remark) {
    this.remark = remark;
  }

  public Date getTktl() {
    return tktl;
  }

  public void setTktl(Date tktl) {
    this.tktl = tktl;
  }

  public double getPrice() {
    return price;
  }

  public void setPrice(double price) {
    this.price = price;
  }

  public double getTax() {
    return tax;
  }

  public void setTax(double tax) {
    this.tax = tax;
  }

  public double getInsurance() {
    return insurance;
  }

  public void setInsurance(double insurance) {
    this.insurance = insurance;
  }

  public double getServiceCharge() {
    return serviceCharge;
  }

  public void setServiceCharge(double serviceCharge) {
    this.serviceCharge = serviceCharge;
  }

  public double getCommRate() {
    return commRate == null ? 0 : commRate;
  }

  public void setCommRate(double commRate) {
    this.commRate = commRate;
  }

  public double getCommission() {
    return commission == null ? 0 : commission;
  }

  public void setCommission(double commission) {
    this.commission = commission;
  }

  public double getDiscountRate() {
    return discountRate;
  }

  public void setDiscountRate(double discountRate) {
    this.discountRate = discountRate;
  }

  public double getDiscount() {
    return discount;
  }

  public void setDiscount(double discount) {
    this.discount = discount;
  }

  public double getTotalAmount() {
    return totalAmount;
  }

  public void setTotalAmount(double totalAmount) {
    this.totalAmount = totalAmount;
  }

  public double getProfit() {
    return profit == null ? 0 : profit;
  }

  public void setProfit(double profit) {
    this.profit = profit;
  }

  public double getAmount() {
    return amount;
  }

  public void setAmount(double amount) {
    this.amount = amount;
  }

  public List<FlightOrderExtra> getExtras() {
    if (extras == null) {
      extras = new ArrayList<>();
    }
    return extras;
  }

  public void setExtras(List<FlightOrderExtra> extras) {
    this.extras = extras;
  }


  public int getPayStatus() {
    return payStatus == null ? 0 : payStatus;
  }

  public void setPayStatus(int payStatus) {
    this.payStatus = payStatus;
  }


  public int getItineraryType() {
    return itineraryType == null ? 0 : itineraryType;
  }

  public void setItineraryType(int itineraryType) {
    this.itineraryType = itineraryType;
  }

  public String getItineraryMailingAddress() {
    return itineraryMailingAddress;
  }

  public void setItineraryMailingAddress(String itineraryMailingAddress) {
    this.itineraryMailingAddress = itineraryMailingAddress;
  }

  public int getItineraryMailingStatus() {
    return itineraryMailingStatus == null ? 0 : itineraryMailingStatus;
  }

  public void setItineraryMailingStatus(int itineraryMailingStatus) {
    this.itineraryMailingStatus = itineraryMailingStatus;
  }

  public String getItineraryMailingMemo() {
    return itineraryMailingMemo;
  }

  public void setItineraryMailingMemo(String itineraryMailingMemo) {
    this.itineraryMailingMemo = itineraryMailingMemo;
  }

  public FlightOrderCancelRequest getCancelRequest() {
    return cancelRequest;
  }

  public void setCancelRequest(FlightOrderCancelRequest cancelRequest) {
    this.cancelRequest = cancelRequest;
  }

  public Date getDeliveryDate() {
    return deliveryDate;
  }

  public void setDeliveryDate(Date deliveryDate) {
    this.deliveryDate = deliveryDate;
  }

  public Date getEtdzDate() {
    return etdzDate;
  }

  public void setEtdzDate(Date etdzDate) {
    this.etdzDate = etdzDate;
  }

  public String getItineraryRecipient() {
    return itineraryRecipient;
  }

  public void setItineraryRecipient(String itineraryRecipient) {
    this.itineraryRecipient = itineraryRecipient;
  }

  public String getItineraryRecipientMobile() {
    return itineraryRecipientMobile;
  }

  public void setItineraryRecipientMobile(String itineraryRecipientMobile) {
    this.itineraryRecipientMobile = itineraryRecipientMobile;
  }

  public String getOrderNo() {
    return orderNo;
  }

  public void setOrderNo(String orderNo) {
    this.orderNo = orderNo;
  }

  public double getCost() {
    return cost == null ? 0 : cost;
  }

  public void setCost(double cost) {
    this.cost = cost;
  }

  public double getTotalCost() {
    return totalCost == null ? 0 : totalCost;
  }

  public void setTotalCost(double totalCost) {
    this.totalCost = totalCost;
  }

  public Integer getItineraryPrintCount() {
    return itineraryPrintCount == null ? 0 : this.itineraryPrintCount;
  }

  public void setItineraryPrintCount(Integer itineraryPrintCount) {
    this.itineraryPrintCount = itineraryPrintCount;
  }

  public String getLinkman() {
    return linkman == null ? "" : linkman.trim();
  }

  public void setLinkman(String linkman) {
    this.linkman = linkman;
  }

  public String getLinkPhone() {
    return linkPhone == null ? "" : linkPhone.trim();
  }

  public void setLinkPhone(String linkPhone) {
    this.linkPhone = linkPhone;
  }

  public int getIntlTicket() {
    return intlTicket == null ? 0 : intlTicket;
  }

  public void setIntlTicket(int intlTicket) {
    this.intlTicket = intlTicket;
  }

  public double getChdAmount() {
    return chdAmount == null ? 0 : chdAmount;
  }

  public void setChdAmount(double amountChd) {
    this.chdAmount = amountChd;
  }

  public double getChdCost() {
    return chdCost == null ? 0 : chdCost;
  }

  public void setChdCost(double costChd) {
    this.chdCost = costChd;
  }

  public double getChdCommission() {
    return chdCommission == null ? 0 : chdCommission;
  }

  public void setChdCommission(double commissionChd) {
    this.chdCommission = commissionChd;
  }

  public double getChdInsurance() {
    return chdInsurance == null ? 0 : chdInsurance;
  }

  public void setChdInsurance(double insuranceChd) {
    this.chdInsurance = insuranceChd;
  }

  public double getChdTax() {
    return chdTax == null ? 0 : chdTax;
  }

  public void setChdTax(double taxChd) {
    this.chdTax = taxChd;
  }

  public double getChdParvalue() {
    return chdParvalue == null ? 0 : chdParvalue;
  }

  public void setChdParvalue(double parvalueChd) {
    this.chdParvalue = parvalueChd;
  }

  public double getChdPrice() {
    return chdPrice == null ? 0 : chdPrice;
  }

  public void setChdPrice(double priceChd) {
    this.chdPrice = priceChd;
  }

  public int getChildCount() {
    return childCount == null ? 0 : childCount;
  }

  public void setChildCount(int childCount) {
    this.childCount = childCount;
  }

  public int getAdultCount() {
    return adultCount == null ? 0 : adultCount;
  }

  public void setAdultCount(int adultCount) {
    this.adultCount = adultCount;
  }

  public double getChdServiceCharge() {
    return chdServiceCharge == null ? 0 : chdServiceCharge;
  }

  public void setChdServiceCharge(double chdServiceCharge) {
    this.chdServiceCharge = chdServiceCharge;
  }

  public double getChdDiscount() {
    return chdDiscount == null ? 0 : chdDiscount;
  }

  public void setChdDiscount(double chdDiscount) {
    this.chdDiscount = chdDiscount;
  }

  public double getInfPrice() {
    return infPrice == null ? 0 : infPrice;
  }

  public void setInfPrice(double infPrice) {
    this.infPrice = infPrice;
  }

  public double getInfParvalue() {
    return infParvalue == null ? 0 : infParvalue;
  }

  public void setInfParvalue(double infParvalue) {
    this.infParvalue = infParvalue;
  }

  public double getInfTax() {
    return infTax == null ? 0 : infTax;
  }

  public void setInfTax(double infTax) {
    this.infTax = infTax;
  }

  public double getInfInsurance() {
    return infInsurance == null ? 0 : infInsurance;
  }

  public void setInfInsurance(double infInsurance) {
    this.infInsurance = infInsurance;
  }

  public double getInfCommission() {
    return infCommission == null ? 0 : infCommission;
  }

  public void setInfCommission(double infCommission) {
    this.infCommission = infCommission;
  }

  public double getInfServiceCharge() {
    return infServiceCharge == null ? 0 : infServiceCharge;
  }

  public void setInfServiceCharge(double infServiceCharge) {
    this.infServiceCharge = infServiceCharge;
  }

  public double getInfDiscount() {
    return infDiscount == null ? 0 : infDiscount;
  }

  public void setInfDiscount(double infDiscount) {
    this.infDiscount = infDiscount;
  }

  public double getInfCost() {
    return infCost == null ? 0 : infCost;
  }

  public void setInfCost(double infCost) {
    this.infCost = infCost;
  }

  public double getInfAmount() {
    return infAmount == null ? 0 : infAmount;
  }

  public void setInfAmount(double infAmount) {
    this.infAmount = infAmount;
  }

  public int getInfantCount() {
    return infantCount == null ? 0 : infantCount;
  }

  public void setInfantCount(int infantCount) {
    this.infantCount = infantCount;
  }

  public int getAutoTicketing() {
    return autoTicketing == null ? -1 : autoTicketing;
  }

  public void setAutoTicketing(int autoTicketing) {
    this.autoTicketing = autoTicketing;
  }

  public int getAutoTicketingPrice() {
    return autoTicketingPrice == null ? 0 : autoTicketingPrice;
  }

  public void setAutoTicketingPrice(int autoTicketingPrice) {
    this.autoTicketingPrice = autoTicketingPrice;
  }

  public int getBillImported() {
    return billImported == null ? 0 : billImported;
  }

  public void setBillImported(int billImported) {
    this.billImported = billImported;
  }

  public String getDeliveryNoteNo() {
    return deliveryNoteNo;
  }

  public void setDeliveryNoteNo(String deliveryNoteNo) {
    this.deliveryNoteNo = deliveryNoteNo;
  }

  public String getKeyCustomerNo() {
    return keyCustomerNo;
  }

  public void setKeyCustomerNo(String keyCustomerNo) {
    this.keyCustomerNo = keyCustomerNo;
  }

  public Integer getBlanketOrderId() {
    return blanketOrderId;
  }

  public void setBlanketOrderId(Integer blanketOrderId) {
    this.blanketOrderId = blanketOrderId;
  }

  public String getPolicyCode() {
    return policyCode;
  }

  public void setPolicyCode(String policyCode) {
    this.policyCode = policyCode;
  }

  public int getPriceChecked() {
    return priceChecked == null ? ORDER_PRICE_VERIFY_STATE_NONE : priceChecked;
  }

  public void setPriceChecked(int priceChecked) {
    this.priceChecked = priceChecked;
  }

  public Date getPriceCheckedTime() {
    return priceCheckedTime;
  }

  public void setPriceCheckedTime(Date priceCheckTime) {
    this.priceCheckedTime = priceCheckTime;
  }

  public OrderApprovalInfo getApprovalInfo() {
    return approvalInfo;
  }

  public void setApprovalInfo(OrderApprovalInfo approvalInfo) {
    this.approvalInfo = approvalInfo;
  }

  public int getPnrRefreshStatus() {
    return pnrRefreshStatus == null ? -1 : pnrRefreshStatus;
  }

  public void setPnrRefreshStatus(Integer pnrRefreshStatus) {
    this.pnrRefreshStatus = pnrRefreshStatus;
  }

  public int getDetrRefreshStatus() {
    return detrRefreshStatus == null ? 0 : detrRefreshStatus;
  }

  public void setDetrRefreshStatus(int detrRefreshStatus) {
    this.detrRefreshStatus = detrRefreshStatus;
  }

  public Date getDetrRefreshTime() {
    return detrRefreshTime;
  }

  public void setDetrRefreshTime(Date detrRefreshTime) {
    this.detrRefreshTime = detrRefreshTime;
  }

  public List<FlightOrderTicket> getTickets() {
    if (tickets == null) {
      tickets = new ArrayList<>();
    }
    return tickets;
  }

  public void setTickets(List<FlightOrderTicket> tickets) {
    this.tickets = tickets;
  }

  public double getCommission2() {
    return commission2 == null ? 0 : commission2;
  }

  public void setCommission2(double commission2) {
    this.commission2 = commission2;
  }

  public double getChdCommission2() {
    return chdCommission2 == null ? 0 : chdCommission2;
  }

  public void setChdCommission2(double chdCommission2) {
    this.chdCommission2 = chdCommission2;
  }

  public double getInfCommission2() {
    return infCommission2 == null ? 0 : infCommission2;
  }

  public void setInfCommission2(double infCommission2) {
    this.infCommission2 = infCommission2;
  }

  public int getBookingChannel() {
    return bookingChannel == null ? -1 : bookingChannel;
  }

  public void setBookingChannel(int bookingChannel) {
    this.bookingChannel = bookingChannel;
  }

  public double getParvalue() {
    return parvalue;
  }

  public void setParvalue(double parvalue) {
    this.parvalue = parvalue;
  }

  public int getGpTicket() {
    return gpTicket == null ? 0 : gpTicket;
  }

  public void setGpTicket(int gpTicket) {
    this.gpTicket = gpTicket;
  }

  public int getNoticeType() {
    return noticeType == null ? 0 : noticeType;
  }

  public void setNoticeType(int noticeType) {
    this.noticeType = noticeType;
  }

  public String getNoticeContent() {
    return noticeContent;
  }

  public void setNoticeContent(String noticeContent) {
    this.noticeContent = noticeContent;
  }

  public int getNoticeConfirmed() {
    return noticeConfirmed == null ? 0 : noticeConfirmed;
  }

  public void setNoticeConfirmed(int noticeConfirmed) {
    this.noticeConfirmed = noticeConfirmed;
  }

  public Date getNoticeTime() {
    return noticeTime == null ? null : (Date) noticeTime.clone();
  }

  public void setNoticeTime(Date noticeTime) {
    this.noticeTime = noticeTime == null ? null : (Date) noticeTime.clone();
  }

  public int getShowStatus() {
    return showStatus == null ? 0 : showStatus;
  }

  public void setShowStatus(Integer showStatus) {
    this.showStatus = showStatus;
  }


  public int getNotifyStatus() {
    return notifyStatus == null ? 0 : notifyStatus;
  }

  public void setNotifyStatus(Integer notifyStatus) {
    this.notifyStatus = notifyStatus;
  }

  public String getExternalOrderNo() {
    return externalOrderNo;
  }

  public void setExternalOrderNo(String externalOrderNo) {
    this.externalOrderNo = externalOrderNo;
  }

  public void calcPsgCount() {
    int adultCount = 0;
    int childCount = 0;
    int infantCount = 0;
    for (var psg : this.getPassengers()) {
      if (psg.getPsgType() == PSG_TYPE_ADU) {
        adultCount++;
      } else if (psg.getPsgType() == PSG_TYPE_CHD) {
        childCount++;
      } else {
        infantCount++;
      }
    }

    this.setAdultCount(adultCount);
    this.setChildCount(childCount);
    this.setInfantCount(infantCount);
  }

  public String getLinkMobile() {
    return linkMobile;
  }

  public void setLinkMobile(String linkMobile) {
    this.linkMobile = linkMobile;
  }

  public String getLinkEmail() {
    return linkEmail;
  }

  public void setLinkEmail(String linkEmail) {
    this.linkEmail = linkEmail;
  }

  public String getBigPnrNo() {
    return bigPnrNo;
  }

  public void setBigPnrNo(String bigPnrNo) {
    this.bigPnrNo = bigPnrNo;
  }

  public Date getSubmitTime() {
    return submitTime;
  }

  public void setSubmitTime(Date submitTime) {
    this.submitTime = submitTime;
  }
}
